#ifndef F437C81F_91CB_4584_B3F4_886033626454
#define F437C81F_91CB_4584_B3F4_886033626454
#pragma once

#include <sys/stat.h>
#include <sys/types.h>
#include <iostream>
#include <cerrno>
#include <cstring>
#include <cstdlib>
#include <unistd.h>
#include <fcntl.h>
#include <cstdio>

#define MODE 0664
#define FILE_PATH "./myfifo"

enum
{
	FIFO_CREATE_ERR = 1,
	FIFO_DELETE_ERR,
	FIFO_OPEN_ERR,
	FIFO_READ_ERR,
	FIFO_WRITE_ERR
};

class Init
{
public:
	Init()
	{
		int n = mkfifo(FILE_PATH, MODE);
		if (n == -1)
		{
			perror("mkfifo:");
			exit(FIFO_CREATE_ERR);
		}
	}
	~Init()
	{
		int ret = unlink(FILE_PATH);
		if (ret == -1)
		{
			perror("unlink");
			exit(FIFO_DELETE_ERR);
		}
	}
};

#endif /* F437C81F_91CB_4584_B3F4_886033626454 */
